<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vue2响应式原理</title>
</head>
<body>
  
</body>
<script>
  const data = {};
  let name = 'Vue';

  Object.defineProperty(data,'name',{
    get:function(){
      console.log('get');
      return name;
    },
    set:function(newVal){
      console.log('set');
      name = newVal;
      // 视图更新渲染
    }
  });
  console.log(data.name);
  data.name = '小笑残虹';
  console.log(data.name);
</script>
</html>